<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>基层AI辅助诊断系统 - 病历模板管理</title>
    <!-- 引入Element Plus的样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css">
    <!-- 引入Vue 3 -->
    <script src="https://unpkg.com/vue@3"></script>
    <!-- 引入Element Plus组件库 -->
    <script src="https://unpkg.com/element-plus"></script>
    <!-- 引入中文语言包 -->
    <script src="https://unpkg.com/element-plus/dist/locale/zh-cn.min.js"></script>
    <style>
        /* 基础样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
            background: #FFFFFF;
            color: var(--text-primary);
            font-size: 14px;
            line-height: 1.5;
            margin: 0;
        }

        /* 色彩系统 - 基于HIS系统现代极简风设计规范 */
        :root {
            /* 主色调 */
            --primary: #0F6CBD;
            --primary-light: #D0E7FF;
            --primary-dark: #0A4F8D;
            
            /* 辅助色 */
            --success: #0F8A5F;
            --warning: #F59337;
            --error: #D13438;
            --info: #0078D4;
            
            /* 中性色 - 文字 */
            --text-primary: #1A1A1A;
            --text-secondary: #4D4D4D;
            --text-tertiary: #767676;
            --text-disabled: #A6A6A6;
            
            /* 中性色 - 边框与分割线 */
            --border-strong: #CCCCCC;
            --border-normal: #E0E0E0;
            --border-light: #F0F0F0;
            --divider: #F5F5F5;
            
            /* 中性色 - 背景 */
            --bg-primary: #FFFFFF;
            --bg-secondary: #F9F9F9;
            --bg-card: #FFFFFF;
            --bg-disabled: #F5F5F5;
            
            /* 医疗专业色 */
            --medical-critical: #B91C1C;
            --medical-abnormal: #F59E0B;
            --medical-normal: #10B981;
            --medical-pending: #3B82F6;
            --medical-completed: #9CA3AF;
            
            /* 间距系统 */
            --spacing-2: 2px;
            --spacing-4: 4px;
            --spacing-8: 8px;
            --spacing-12: 12px;
            --spacing-16: 16px;
            --spacing-24: 24px;
            --spacing-32: 32px;
            --spacing-40: 40px;
            --spacing-48: 48px;
            
            /* 字体大小 */
            --font-page-title: 20px;
            --font-card-title: 16px;
            --font-table-title: 14px;
            --font-body: 14px;
            --font-table: 13px;
            --font-small: 12px;
            
            /* 行高 */
            --line-height-title: 1.4;
            --line-height-body: 1.5;
            --line-height-table: 1.2;
            --line-height-form: 1.4;
            
            /* 圆角 */
            --radius-small: 2px;
            --radius-medium: 4px;
            
            /* 动画时间 */
            --transition-fast: 150ms;
            --transition-normal: 200ms;
            --transition-slow: 300ms;
            
            /* 导航统一宽度 */
            --nav-item-width: 140px;
        }

        [v-cloak] {
            display: none;
        }

        /* 布局容器 */
        .container {
            width: 100%;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            background-color: var(--bg-secondary);
        }

        /* 顶部导航栏 */
        .header {
            height: 60px;
            background-color: var(--bg-primary);
            border-bottom: 1px solid var(--border-normal);
            display: flex;
            align-items: center;
            padding: 0 var(--spacing-24);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
            position: relative;
            z-index: 100;
        }

        .header-spacer {
            width: 200px;
            flex-shrink: 0;
        }

        #app-nav {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            z-index: 10;
            width: calc(100% - 400px); /* 两侧各200px 对称留白 */
            display: flex;
            justify-content: center;
        }
        
        /* Element Plus菜单样式覆盖 */
        .el-menu {
            border: none !important;
            background-color: transparent !important;
        }
        
        .el-menu--horizontal > .el-menu-item,
        .el-menu--horizontal > .el-sub-menu .el-sub-menu__title {
            height: 60px;
            line-height: 60px;
            color: var(--text-secondary);
            font-weight: 500;
            font-size: var(--font-body);
            padding: 0;
            width: var(--nav-item-width);
            text-align: center;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
        }

        .el-sub-menu__icon-arrow { display: none !important; }

        .el-menu--horizontal > .el-sub-menu .el-sub-menu__title::after {
            content: '';
            display: inline-block;
            width: 16px;
            height: 16px;
            margin-left: 8px;
            background-repeat: no-repeat;
            background-position: center;
            background-size: 16px 16px;
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23767676' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
        }

        .el-sub-menu:hover > .el-sub-menu__title::after,
        .el-sub-menu.is-active > .el-sub-menu__title::after {
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230F6CBD' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
        }

        .el-sub-menu.is-opened > .el-sub-menu__title::after {
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230F6CBD' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 15 12 9 18 15'/></svg>");
        }
        
        .el-menu--horizontal > .el-menu-item.is-active,
        .el-menu--horizontal > .el-sub-menu.is-active .el-sub-menu__title {
            color: var(--primary) !important;
            border-bottom: 2px solid var(--primary);
            font-weight: 500;
        }
        
        .el-menu--horizontal > .el-menu-item:not(.is-disabled):hover,
        .el-menu--horizontal > .el-menu-item:not(.is-disabled):focus,
        .el-menu--horizontal > .el-sub-menu:not(.is-disabled):hover .el-sub-menu__title {
            color: var(--primary);
            background-color: transparent;
        }
        
        /* 下拉菜单样式覆盖 */
        .el-menu--popup {
            width: var(--nav-item-width) !important;
            min-width: var(--nav-item-width) !important;
            max-width: var(--nav-item-width) !important;
            border-radius: var(--radius-small);
            padding: 4px 0;
            border: 1px solid var(--border-light);
            border-top: 2px solid var(--primary);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            text-align: center !important;
        }
        
        .el-menu--popup .el-menu-item {
            height: 36px;
            line-height: 36px;
            padding: 0 !important;
            color: var(--text-secondary);
            white-space: nowrap;
            text-align: center;
            width: var(--nav-item-width) !important;
            box-sizing: border-box;
            overflow: hidden;
            text-overflow: ellipsis;
            display: flex !important;
            justify-content: center !important;
            align-items: center !important;
            font-size: var(--font-body);
        }
        
        .el-menu--popup .el-menu-item:hover {
            background-color: var(--bg-secondary);
            color: var(--primary);
        }

        .user-section {
            display: flex;
            align-items: center;
            gap: var(--spacing-16);
            margin-left: auto;
            z-index: 10;
            width: 200px;
            justify-content: flex-end;
            flex-shrink: 0;
            cursor: pointer;
            padding: 8px 12px;
            border-radius: var(--radius-small);
            transition: background-color var(--transition-fast);
            color: var(--text-secondary);
        }

        .user-section:hover {
            background-color: var(--bg-secondary);
        }

        .user-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background-color: var(--primary-light);
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--primary);
            font-weight: 500;
        }

        .user-name {
            font-weight: 500;
            font-size: var(--font-body);
            color: var(--text-secondary);
        }

        .user-arrow {
            color: var(--text-tertiary);
            transition: color var(--transition-normal);
        }

        .user-section:hover .user-arrow {
            color: var(--primary);
        }

        /* 用户下拉弹窗 */
        .user-dropdown {
            position: absolute;
            top: 60px; /* 紧贴头部底部 */
            right: var(--spacing-24);
            width: 160px;
            background: var(--bg-primary);
            border: 1px solid var(--border-light);
            border-radius: var(--radius-small);
            box-shadow: 0 4px 12px rgba(0,0,0,0.08);
            display: none;
            z-index: 200;
            overflow: hidden;
        }

        .user-dropdown .item {
            padding: 10px 12px;
            color: var(--text-secondary);
            font-size: var(--font-body);
            cursor: pointer;
            white-space: nowrap;
        }

        .user-dropdown .item:hover {
            background-color: var(--bg-secondary);
            color: var(--primary);
        }
        
        /* 主要内容区域样式 */
        .main-content {
            display: flex;
            flex-direction: column;
            flex: 1;
            min-height: calc(100vh - 60px);
            background-color: var(--bg-primary);
            width: 100%;
        }
        
        .page-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: var(--spacing-16) var(--spacing-24);
            border-bottom: 1px solid var(--border-light);
        }
        
        .page-title {
            font-size: var(--font-page-title);
            font-weight: 600;
            color: var(--text-primary);
            line-height: var(--line-height-title);
            margin: 0;
        }
        
        /* 主要内容布局 */
        .content-layout {
            display: flex;
            flex: 1;
        }
        
        /* 模板分类区域 - 左侧面板 */
        .category-panel {
            width: 280px;
            background-color: var(--bg-primary);
            border-right: 1px solid var(--border-light);
            display: flex;
            flex-direction: column;
            flex-shrink: 0;
        }
        
        .panel-header {
            padding: var(--spacing-16);
            border-bottom: 1px solid var(--border-light);
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: var(--spacing-8);
        }
        
        .category-list {
            flex: 1;
            overflow-y: auto;
            padding: var(--spacing-12);
        }
        
        .category-item {
            padding: var(--spacing-8) var(--spacing-12);
            cursor: pointer;
            transition: background-color var(--transition-fast);
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-radius: var(--radius-small);
            margin: var(--spacing-4) 0;
        }
        
        .category-item:hover {
            background-color: var(--bg-secondary);
        }
        
        .category-item.active {
            background-color: var(--primary-light);
            color: var(--primary);
            font-weight: 500;
        }
        
        .category-item .edit-icons {
            display: none;
        }
        
        .category-item.edit-mode .edit-icons {
            display: flex;
            gap: var(--spacing-8);
        }
        
        .edit-icon {
            width: 16px;
            height: 16px;
            cursor: pointer;
            color: var(--text-tertiary);
        }
        
        .edit-icon:hover {
            color: var(--primary);
        }
        
        /* 模板列表区域 - 右侧内容 */
        .template-panel {
            flex: 1;
            background-color: var(--bg-primary);
            display: flex;
            flex-direction: column;
            overflow: auto;
        }
        
        .content-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: var(--spacing-16) var(--spacing-24);
            border-bottom: 1px solid var(--border-light);
        }
        
        
        .action-bar {
            display: flex;
            gap: var(--spacing-8);
        }
        
        .template-list {
            flex: 1;
            padding: var(--spacing-24);
            overflow: auto;
        }
        
        /* 表格样式 */
        .template-table {
            width: 100%;
            border-collapse: collapse;
        }
        
        .template-table th {
            background-color: var(--bg-secondary);
            padding: var(--spacing-12) var(--spacing-16);
            text-align: left;
            font-weight: 600;
            color: var(--text-secondary);
            border-bottom: 1px solid var(--border-normal);
            height: 40px;
            font-size: var(--font-table-title);
        }
        
        .template-table td {
            padding: var(--spacing-12) var(--spacing-16);
            border-bottom: 1px solid var(--border-light);
            color: var(--text-secondary);
            height: 40px;
            vertical-align: middle;
            font-size: var(--font-table);
        }
        
        .template-table tr:hover {
            background-color: var(--bg-secondary);
        }
        
        .template-table tr:last-child td {
            border-bottom: none;
        }
        
        /* 操作按钮样式 */
        .btn {
            padding: var(--spacing-8) var(--spacing-16);
            border-radius: var(--radius-small);
            font-size: var(--font-body);
            font-weight: 500;
            cursor: pointer;
            border: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: all var(--transition-normal);
            gap: var(--spacing-8);
            height: 36px;
            line-height: 1;
            white-space: nowrap;
        }
        
        .panel-header .btn {
            padding: var(--spacing-8) var(--spacing-12);
            width: 100%;
        }
        
        .btn .icon,
        .btn .btn-icon {
            flex-shrink: 0;
            margin-right: var(--spacing-8);
        }
        
        .btn-primary {
            background-color: var(--primary);
            color: white;
        }
        
        .btn-primary:hover {
            background-color: var(--primary-dark);
        }
        
        .btn-primary:active {
            background-color: var(--primary-dark);
            transform: translateY(1px);
        }
        
        .btn-default {
            background-color: var(--bg-secondary);
            color: var(--text-secondary);
            border: 1px solid var(--border-normal);
            min-width: 80px;
        }
        
        .btn-default:hover {
            background-color: var(--bg-primary);
            border-color: var(--border-strong);
            color: var(--text-primary);
        }
        
        .btn-default:active {
            background-color: var(--bg-secondary);
            transform: translateY(1px);
        }
        
        /* 操作链接样式 */
        .operations {
            display: inline-flex;
            gap: var(--spacing-8);
        }
        
        .operation-link {
            color: var(--primary);
            text-decoration: none;
            cursor: pointer;
        }
        
        .operation-link:hover {
            color: var(--primary-dark);
        }
        
        .delete-template {
            color: var(--error);
        }
        
        .delete-template:hover {
            color: #B91C1C;
        }
        
        /* 分页控件样式 */
        .pagination-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: var(--spacing-16);
            border-top: 1px solid var(--border-light);
        }
        
        .pagination-text {
            color: var(--text-tertiary);
            font-size: var(--font-small);
        }
        
        .pagination-controls {
            display: flex;
            align-items: center;
            gap: var(--spacing-16);
        }
        
        .page-numbers {
            display: flex;
            gap: var(--spacing-8);
        }
        
        .page-numbers button {
            min-width: 32px;
            height: 32px;
            border-radius: var(--radius-small);
            border: 1px solid var(--border-normal);
            background: var(--bg-primary);
            cursor: pointer;
            color: var(--text-secondary);
            transition: all var(--transition-normal);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: var(--font-small);
        }
        
        .page-numbers button:hover {
            border-color: var(--primary);
            color: var(--primary);
        }
        
        .page-numbers button.active {
            background: var(--primary);
            border-color: var(--primary);
            color: #FFFFFF;
        }
        
        .pagination-size {
            display: flex;
            align-items: center;
            gap: var(--spacing-8);
            color: var(--text-secondary);
            font-size: var(--font-small);
        }
        
        .page-size-selector {
            height: 32px;
            border: 1px solid var(--border-normal);
            border-radius: var(--radius-small);
            padding: 0 var(--spacing-8);
            font-size: var(--font-small);
            margin: 0 var(--spacing-4);
        }
        
        /* 分类编辑模式样式 */
        .edit-mode-active .category-item {
            padding-right: var(--spacing-40);
            position: relative;
        }
        
        .edit-mode-active .edit-icons {
            position: absolute;
            right: var(--spacing-12);
            display: flex;
            gap: var(--spacing-8);
        }
        
        /* 弹窗样式 */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.5);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            opacity: 0;
            visibility: hidden;
            transition: opacity var(--transition-normal) ease-out;
            backdrop-filter: blur(2px);
        }
        
        .modal-overlay[style*="display: flex"] {
            opacity: 1;
            visibility: visible;
        }
        
        .modal {
            background-color: var(--bg-primary);
            border-radius: var(--radius-small);
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
            width: 400px;
            max-width: 90%;
            overflow: hidden;
            transform: scale(0.95);
            transition: transform var(--transition-normal) ease-out;
        }
        
        .modal-overlay[style*="display: flex"] .modal {
            transform: scale(1);
        }
        
        .modal-header {
            padding: var(--spacing-16);
            border-bottom: 1px solid var(--border-light);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .modal-title {
            font-size: var(--font-card-title);
            font-weight: 600;
            color: var(--text-primary);
        }
        
        .modal-close {
            cursor: pointer;
            color: var(--text-tertiary);
        }
        
        .modal-close:hover {
            color: var(--text-primary);
        }
        
        .modal-body {
            padding: var(--spacing-16);
        }
        
        .modal-footer {
            padding: var(--spacing-16);
            border-top: 1px solid var(--border-light);
            display: flex;
            justify-content: flex-end;
            gap: var(--spacing-16);
        }
        
        /* 表单样式 */
        .form-group {
            margin-bottom: var(--spacing-16);
        }
        
        .form-label {
            display: block;
            margin-bottom: var(--spacing-8);
            font-weight: 500;
            color: var(--text-secondary);
        }
        
        .form-control {
            width: 100%;
            padding: var(--spacing-8) var(--spacing-12);
            border: 1px solid var(--border-normal);
            border-radius: var(--radius-small);
            font-size: var(--font-body);
            color: var(--text-primary);
            transition: border-color var(--transition-normal);
        }
        
        .form-control:focus {
            border-color: var(--primary);
            outline: none;
            box-shadow: 0 0 0 2px rgba(15, 108, 189, 0.2);
        }
        
        /* 响应式样式 */
        @media (max-width: 768px) {
            .header {
                flex-wrap: wrap;
                padding: var(--spacing-12) var(--spacing-16);
                height: auto;
            }
            
            .header-spacer {
                width: 100%;
                justify-content: center;
                margin-bottom: 8px;
            }
            
            .user-section {
                width: 100%;
                justify-content: center;
                order: 3;
                margin-top: 8px;
            }
            
            #app-nav {
                position: relative;
                left: 0;
                transform: none;
                width: 100%;
                order: 3;
                margin-top: var(--spacing-8);
            }
            
            /* 移动端菜单样式覆盖 */
            .el-menu--collapse {
                width: 100%;
            }
            
            .el-menu--horizontal {
                flex-wrap: wrap;
                width: 100%;
                overflow-x: auto;
                white-space: nowrap;
                -webkit-overflow-scrolling: touch;
                padding-bottom: var(--spacing-4);
                justify-content: center;
            }
            
            .el-menu--horizontal > .el-menu-item,
            .el-menu--horizontal > .el-sub-menu .el-sub-menu__title {
                height: 48px;
                line-height: 48px;
            }
            
            /* 移动端下拉菜单样式 */
            .el-menu--popup {
                position: fixed;
                top: auto !important;
                left: 0 !important;
                right: 0 !important;
                width: 100%;
                max-height: 60vh;
                overflow-y: auto;
                border-radius: 8px 8px 0 0;
            }
            
            .page-header {
                padding: var(--spacing-12) var(--spacing-16);
            }
            
            .panel-header {
                grid-template-columns: 1fr;
                gap: var(--spacing-8);
            }
            
            .content-layout {
                flex-direction: column;
            }
            
            .category-panel {
                width: 100%;
                border-right: none;
                border-bottom: 1px solid var(--border-light);
            }
            
            .template-table {
                min-width: 600px;
            }
            
            .template-list {
                padding: var(--spacing-16);
            }
            
            .pagination-container {
                flex-direction: column;
                gap: var(--spacing-16);
                align-items: flex-start;
            }
            
            .pagination-controls {
                flex-direction: column;
                align-items: flex-start;
                gap: var(--spacing-12);
                width: 100%;
            }
            
            .page-numbers {
                flex-wrap: wrap;
            }
            
            .modal {
                width: 95%;
                max-width: none;
            }
        }
    </style>
</head>
<body>
    <div id="app" class="container">
        <!-- 顶部导航栏 - 使用Element Plus组件 -->
        <header class="header">
            <div class="header-spacer"></div>
            <div id="app-nav">
                <el-menu 
                    :default-active="activeIndex" 
                    class="el-menu-demo" 
                    mode="horizontal" 
                    @select="handleSelect"
                    :ellipsis="false"
                    :popper-offset="0"
                    popper-class="custom-dropdown">
                    <el-menu-item index="1">开始问诊</el-menu-item>
                    <el-sub-menu index="2" popper-class="custom-dropdown">
                        <template #title>病历管理</template>
                        <el-menu-item index="2-1">病历查询</el-menu-item>
                        <el-menu-item index="2-2">病历模板</el-menu-item>
                        <el-menu-item index="2-3">个人药品</el-menu-item>
                    </el-sub-menu>
                    <el-menu-item index="3">患者管理</el-menu-item>
                    <el-sub-menu index="4" popper-class="custom-dropdown">
                        <template #title>数据统计</template>
                        <el-menu-item index="4-1">诊断统计</el-menu-item>
                        <el-menu-item index="4-2">宏观统计</el-menu-item>
                    </el-sub-menu>
                    <el-menu-item index="5">医学知识</el-menu-item>
                    <el-sub-menu index="6" popper-class="custom-dropdown">
                        <template #title>基础数据</template>
                        <el-menu-item index="6-1">药品管理</el-menu-item>
                    </el-sub-menu>
                    <el-sub-menu index="7" popper-class="custom-dropdown">
                        <template #title>消息通知</template>
                        <el-menu-item index="7-1">通知查看</el-menu-item>
                        <el-menu-item index="7-2">通知发布</el-menu-item>
                    </el-sub-menu>
                    <el-sub-menu index="8" popper-class="custom-dropdown">
                        <template #title>用户管理</template>
                        <el-menu-item index="8-1">用户管理</el-menu-item>
                        <el-menu-item index="8-2">角色管理</el-menu-item>
                    </el-sub-menu>
                </el-menu>
            </div>
            <div class="user-section" id="userSection">
                <span class="user-name">张医生</span>
                <svg class="user-arrow" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                    <polyline points="6 9 12 15 18 9"></polyline>
                </svg>
            </div>
            <div class="user-dropdown" id="userDropdown">
                <div class="item">个人中心</div>
                <div class="item">退出登录</div>
            </div>
        </header>
        
        <!-- 主要内容区域 -->
        <div class="main-content">
            <div class="page-header">
                <h1 class="page-title">病历模板管理</h1>
                <button id="addTemplateBtn" class="btn btn-primary">新增模板</button>
            </div>
            
            <!-- 内容布局 -->
            <div class="content-layout">
                <!-- 模板分类区域 - 左侧面板 -->
                <div class="category-panel">
                <div class="panel-header">
                    <button id="addCategoryBtn" class="btn btn-primary">新增分类</button>
                    <button id="editCategoryBtn" class="btn btn-default">编辑分类</button>
                </div>
                    <div id="categoryList" class="category-list">
                        <div class="category-item active">
                            <span>常见感冒</span>
                            <div class="edit-icons">
                                <svg class="edit-icon edit-btn" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                    <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path>
                                    <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path>
                                </svg>
                                <svg class="edit-icon delete-btn" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                    <polyline points="3 6 5 6 21 6"></polyline>
                                    <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
                                    <line x1="10" y1="11" x2="10" y2="17"></line>
                                    <line x1="14" y1="11" x2="14" y2="17"></line>
                                </svg>
                            </div>
                        </div>
                        <div class="category-item">
                            <span>上呼吸道感染</span>
                            <div class="edit-icons">
                                <svg class="edit-icon edit-btn" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                    <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path>
                                    <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path>
                                </svg>
                                <svg class="edit-icon delete-btn" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                    <polyline points="3 6 5 6 21 6"></polyline>
                                    <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
                                    <line x1="10" y1="11" x2="10" y2="17"></line>
                                    <line x1="14" y1="11" x2="14" y2="17"></line>
                                </svg>
                            </div>
                        </div>
                        <div class="category-item">
                            <span>高血压</span>
                            <div class="edit-icons">
                                <svg class="edit-icon edit-btn" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                    <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path>
                                    <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path>
                                </svg>
                                <svg class="edit-icon delete-btn" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                    <polyline points="3 6 5 6 21 6"></polyline>
                                    <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
                                    <line x1="10" y1="11" x2="10" y2="17"></line>
                                    <line x1="14" y1="11" x2="14" y2="17"></line>
                                </svg>
                            </div>
                        </div>
                        <div class="category-item">
                            <span>糖尿病</span>
                            <div class="edit-icons">
                                <svg class="edit-icon edit-btn" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                    <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path>
                                    <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path>
                                </svg>
                                <svg class="edit-icon delete-btn" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                    <polyline points="3 6 5 6 21 6"></polyline>
                                    <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
                                    <line x1="10" y1="11" x2="10" y2="17"></line>
                                    <line x1="14" y1="11" x2="14" y2="17"></line>
                                </svg>
                            </div>
                        </div>
                        <div class="category-item">
                            <span>消化不良</span>
                            <div class="edit-icons">
                                <svg class="edit-icon edit-btn" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                    <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path>
                                    <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path>
                                </svg>
                                <svg class="edit-icon delete-btn" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                    <polyline points="3 6 5 6 21 6"></polyline>
                                    <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
                                    <line x1="10" y1="11" x2="10" y2="17"></line>
                                    <line x1="14" y1="11" x2="14" y2="17"></line>
                                </svg>
                            </div>
                        </div>
                        <div class="category-item">
                            <span>腰肌劳损</span>
                            <div class="edit-icons">
                                <svg class="edit-icon edit-btn" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                    <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path>
                                    <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path>
                                </svg>
                                <svg class="edit-icon delete-btn" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                    <polyline points="3 6 5 6 21 6"></polyline>
                                    <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
                                    <line x1="10" y1="11" x2="10" y2="17"></line>
                                    <line x1="14" y1="11" x2="14" y2="17"></line>
                                </svg>
                            </div>
                        </div>
                        <div class="category-item">
                            <span>皮肤过敏</span>
                            <div class="edit-icons">
                                <svg class="edit-icon edit-btn" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                    <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path>
                                    <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path>
                                </svg>
                                <svg class="edit-icon delete-btn" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                    <polyline points="3 6 5 6 21 6"></polyline>
                                    <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
                                    <line x1="10" y1="11" x2="10" y2="17"></line>
                                    <line x1="14" y1="11" x2="14" y2="17"></line>
                                </svg>
                            </div>
                        </div>
                        <div class="category-item">
                            <span>儿童发热</span>
                            <div class="edit-icons">
                                <svg class="edit-icon edit-btn" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                    <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path>
                                    <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path>
                                </svg>
                                <svg class="edit-icon delete-btn" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                    <polyline points="3 6 5 6 21 6"></polyline>
                                    <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
                                    <line x1="10" y1="11" x2="10" y2="17"></line>
                                    <line x1="14" y1="11" x2="14" y2="17"></line>
                                </svg>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- 模板列表区域 - 右侧内容 -->
                <div class="template-panel">
                    <div class="template-list">
                        <div class="table-container">
                            <table class="template-table">
                            <thead>
                                <tr>
                                    <th>模板名称</th>
                                    <th>创建时间</th>
                                    <th>使用次数</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>感冒模板</td>
                                    <td>2025-09-01</td>
                                    <td>42</td>
                                    <td>
                                        <div class="operations">
                                            <a class="operation-link edit-template">编辑</a>
                                            <a class="operation-link delete-template">删除</a>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>高血压模板</td>
                                    <td>2025-08-15</td>
                                    <td>28</td>
                                    <td>
                                        <div class="operations">
                                            <a class="operation-link edit-template">编辑</a>
                                            <a class="operation-link delete-template">删除</a>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>糖尿病模板</td>
                                    <td>2025-07-20</td>
                                    <td>35</td>
                                    <td>
                                        <div class="operations">
                                            <a class="operation-link edit-template">编辑</a>
                                            <a class="operation-link delete-template">删除</a>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        </div>
                        <div class="pagination-container">
                            <div class="pagination-text">共 25 条记录</div>
                            <div class="pagination-controls">
                            <div class="page-numbers">
                                <button class="active">1</button>
                                <button>2</button>
                                <button>3</button>
                                <button>4</button>
                                <button>5</button>
                            </div>
                            <div class="pagination-size">
                                每页显示
                                <select class="page-size-selector">
                                    <option value="10">10</option>
                                    <option value="20">20</option>
                                    <option value="50">50</option>
                                </select>
                                条
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 分类编辑/新增弹窗 -->
            <div id="categoryModal" class="modal-overlay" style="display: none;">
                <div class="modal">
                    <div class="modal-header">
                        <h3 class="modal-title">分类编辑</h3>
                        <span class="modal-close" id="closeCategoryModal">×</span>
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <label class="form-label" for="categoryName">分类名称:</label>
                            <input type="text" id="categoryName" class="form-control">
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button id="saveCategoryBtn" class="btn btn-primary">保存</button>
                        <button id="cancelCategoryBtn" class="btn btn-default">取消</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- JavaScript 交互逻辑 -->
    <script>
        // 创建Vue应用
        document.addEventListener('DOMContentLoaded', function() {
            const { createApp, ref } = Vue;
            
            // 创建导航菜单Vue应用
            const navApp = createApp({
                setup() {
                    const activeIndex = ref('2-2'); // 默认选中"病历模板"
                    
                    const handleSelect = (key, keyPath) => {
                        console.log(key, keyPath);
                        // 这里可以添加导航逻辑，如页面跳转等
                    };
                    
                    return {
                        activeIndex,
                        handleSelect
                    };
                }
            });
            
            // 使用Element Plus
            navApp.use(ElementPlus, {
                locale: ElementPlusLocaleZhCn
            });
            
            // 挂载Vue应用
            navApp.mount('#app-nav');

            // 用户下拉菜单
            const userSection = document.getElementById('userSection');
            const userDropdown = document.getElementById('userDropdown');
            
            if (userSection && userDropdown) {
                userSection.addEventListener('click', function(e) {
                    e.stopPropagation();
                    const isOpen = userDropdown.style.display === 'block';
                    userDropdown.style.display = isOpen ? 'none' : 'block';
                });

                document.addEventListener('click', function() {
                    userDropdown.style.display = 'none';
                });
            }
            
            // 分类列表交互
            const categoryList = document.getElementById('categoryList');
            const categoryItems = categoryList.querySelectorAll('.category-item');
            const editCategoryBtn = document.getElementById('editCategoryBtn');
            const addCategoryBtn = document.getElementById('addCategoryBtn');
            const categoryModal = document.getElementById('categoryModal');
            const closeCategoryModal = document.getElementById('closeCategoryModal');
            const saveCategoryBtn = document.getElementById('saveCategoryBtn');
            const cancelCategoryBtn = document.getElementById('cancelCategoryBtn');
            const categoryNameInput = document.getElementById('categoryName');
            
            // 分类项点击事件
            categoryItems.forEach(item => {
                item.addEventListener('click', function() {
                    // 如果不是编辑模式，则切换选中状态
                    if (!categoryList.classList.contains('edit-mode-active')) {
                        categoryItems.forEach(i => i.classList.remove('active'));
                        this.classList.add('active');
                    }
                });
            });
            
            // 编辑按钮点击事件
            editCategoryBtn.addEventListener('click', function() {
                if (categoryList.classList.contains('edit-mode-active')) {
                    // 退出编辑模式
                    categoryList.classList.remove('edit-mode-active');
                    this.textContent = '编辑';
                } else {
                    // 进入编辑模式
                    categoryList.classList.add('edit-mode-active');
                    this.textContent = '完成';
                }
            });
            
            // 新增分类按钮点击事件
            addCategoryBtn.addEventListener('click', function() {
                categoryNameInput.value = '';
                categoryModal.style.display = 'flex';
            });
            
            // 关闭分类弹窗
            function closeCategoryModalFunc() {
                categoryModal.style.display = 'none';
            }
            
            closeCategoryModal.addEventListener('click', closeCategoryModalFunc);
            cancelCategoryBtn.addEventListener('click', closeCategoryModalFunc);
            
            // 保存分类
            saveCategoryBtn.addEventListener('click', function() {
                const categoryName = categoryNameInput.value.trim();
                if (categoryName) {
                    // 在实际应用中，这里会发送请求到服务器保存分类
                    alert(`已保存分类: ${categoryName}`);
                    closeCategoryModalFunc();
                } else {
                    alert('请输入分类名称');
                }
            });
            
            // 编辑和删除分类按钮
            const editBtns = document.querySelectorAll('.edit-btn');
            const deleteBtns = document.querySelectorAll('.delete-btn');
            
            editBtns.forEach(btn => {
                btn.addEventListener('click', function(e) {
                    e.stopPropagation();
                    const categoryItem = this.closest('.category-item');
                    const categoryName = categoryItem.querySelector('span').textContent;
                    categoryNameInput.value = categoryName;
                    categoryModal.style.display = 'flex';
                });
            });
            
            deleteBtns.forEach(btn => {
                btn.addEventListener('click', function(e) {
                    e.stopPropagation();
                    const categoryItem = this.closest('.category-item');
                    const categoryName = categoryItem.querySelector('span').textContent;
                    if (confirm(`确定要删除分类 "${categoryName}" 吗？`)) {
                        // 在实际应用中，这里会发送请求到服务器删除分类
                        alert(`已删除分类: ${categoryName}`);
                    }
                });
            });
            
            // 模板操作
            const addTemplateBtn = document.getElementById('addTemplateBtn');
            const editTemplateBtns = document.querySelectorAll('.edit-template');
            const deleteTemplateBtns = document.querySelectorAll('.delete-template');
            
            addTemplateBtn.addEventListener('click', function() {
                // 在实际应用中，这里会跳转到模板编辑页面
                alert('跳转到模板新增页面');
            });
            
            editTemplateBtns.forEach(btn => {
                btn.addEventListener('click', function() {
                    const templateName = this.closest('tr').querySelector('td').textContent;
                    // 在实际应用中，这里会跳转到模板编辑页面
                    alert(`编辑模板: ${templateName}`);
                });
            });
            
            deleteTemplateBtns.forEach(btn => {
                btn.addEventListener('click', function() {
                    const templateName = this.closest('tr').querySelector('td').textContent;
                    if (confirm(`确定要删除模板 "${templateName}" 吗？`)) {
                        // 在实际应用中，这里会发送请求到服务器删除模板
                        alert(`已删除模板: ${templateName}`);
                    }
                });
            });
            
            // 分页控件
            const pageButtons = document.querySelectorAll('.page-numbers button');
            const pageSizeSelector = document.querySelector('.page-size-selector');
            
            pageButtons.forEach(btn => {
                btn.addEventListener('click', function() {
                    pageButtons.forEach(b => b.classList.remove('active'));
                    this.classList.add('active');
                    // 在实际应用中，这里会发送请求到服务器获取对应页码的数据
                });
            });
            
            pageSizeSelector.addEventListener('change', function() {
                // 在实际应用中，这里会发送请求到服务器获取对应每页条数的数据
                console.log(`每页显示 ${this.value} 条`);
            });
        });
    </script>
</body>
</html>
